package com.cuz.hot100;

public class Q69Sqrt {
    public static void main(String[] args) {

        System.out.println(mySqrt1(2147395599));
    }
    public static int mySqrt1(int x) {
        if (x == 0 || x == 1) {
            return x;
        }
        int left = 0;
        int right = x;
        while (left + 1 != right) {
            int mid = left + ((right - left) >> 1);
            long sqrt = (long) mid * mid;
            if (sqrt > x) {
                right=mid;
            }else {
                left=mid;
            }
        }
        return left;
    }
}
